<template>
	<view v-if="init" class="page_main" :style="{'--color':vuex_config.themeColor1}">
		<!-- 管理端扫码、从历史记录进来 -->
		<template v-if="detail.pk_id?true:false">
			<view class="page_item" v-if="userInfo.pk_id?true:false">
				<view class="img">
					<image :src="userInfo.headimgurl"></image>
				</view>
				<view class="txt">
					<view class="nick_name">{{userInfo.nickname}}</view>
				</view>
			</view>
			<show-edit :detail="detail" :parameter="parameter" :adminOptin="adminOptin" :option="option"></show-edit>

			<template v-if="detail.price && detail.pay_status == 0">
				<view class="fix_bot_main">
					<view class="fixed_bottom_btn">
						<view class="word">未支付</view>
					</view>
				</view>
			</template>
			<template v-else>
				<view class="fix_bot_main" v-if="parameter.examine == 1">
					<view class="fixed_bottom_btn">
						<view class="word">{{ examineObj[detail.status] }}</view>
					</view>
				</view>
				<view class="fix_bot_main" v-else-if="detail.sign_in == 1">
					<view class="fixed_bottom_btn">
						<view class="word">{{ detail.sign_in_time ? '已签到' : '未签到' }}</view>
					</view>
				</view>
			</template>
		</template>
		<view v-else class="no_box">查无信息</view>
	</view>
</template>

<script>
	import {
		edit
	} from '../edit.js';
	import showEdit from '../editComponents/showEdit.vue';
	export default {
		mixins: [edit],
		components: {
			'show-edit': showEdit
		},
		data() {
			return {
				detail: {},
				formId: null,
				userId: null,
				init: false,
				userInfo: {},
				examineObj: {
					0: '无需审核',
					1: '待审核',
					2: '已完成',
				}
			};
		},
		onLoad(options) {
			if (options && options.id) {
				this.formId = Number(options.id);
				this.userId = Number(options.users_id);
				this.getUserInfo();
				this.getDetail();
			} else if (options && options.isHistory) {
				let pages = getCurrentPages();
				let prePage = pages[pages.length - 2].$vm
				this.userInfo = {
					...this.vuex_user
				}
				this.detail = {
					...prePage.detail || {}
				}
				this.initPage();
				this.init = true
			}
		},

		methods: {
			getDetail() {
				this.$loading();
				let params = {
					pk_id: this.formId,
					users_id: this.userId
				};
				this.$resPost('GetCustomFormValInfo', params).then(({
					data
				}) => {
					this.detail = {
						...data
					};
					this.initPage();
					this.init = true;
					this.$hide();
				});
			},
			getUserInfo() {
				this.$resPost('GetUsersInfo', {
					users_id: this.userId
				}).then(({
					data
				}) => {
					this.userInfo = {
						...data
					};
				});
			}
		}
	};
</script>
<style>
	page {
		background-color: #f5f5f5;
	}
</style>
<style scoped lang="scss">
	.page_main {
		padding: 0 30rpx 20rpx;
		color: #000;
	}

	.page_item {
		margin-top: 20rpx;
		background-color: #fff;
		border-radius: 10rpx;
		overflow: hidden;
		border: 1px solid #eee;
		padding: 20rpx 30rpx;
		display: flex;
		align-items: center;

		.img {
			width: 80rpx;
			height: 80rpx;
			border-radius: 50%;
			overflow: hidden;
			background-color: #f5f5f5;
			margin-right: 20rpx;
		}
	}

	.no_box {
		text-align: center;
		color: #666;
		font-size: 38rpx;
	}
</style>
